<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set var="jpath" value="${pageContext.request.contextPath}" />
<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<title>页面API中文抽离版</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0"/>
		<script type="text/javascript">
			window.jQuery || document.write("<script src='${jpath}/static/assets/js/jquery-2.0.3.min.js'>"+"<"+"script>");
		</script>
		<script type="text/javascript">
			if("ontouchend" in document) document.write("<script src='${jpath}/static/assets/js/jquery.mobile.custom.min.js'>"+"<"+"script>");
		</script>
		<script src="${jpath}/static/assets/js/jquery.mobile.custom.min.js"></script>
		<!-- basic styles -->
		<link href="${jpath}/static/assets/css/bootstrap.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="${jpath}/static/assets/css/font-awesome.min.css" />

		<link rel="stylesheet" href="${jpath}/static/assets/css/ace.min.css" />
		<link rel="stylesheet" href="${jpath}/static/assets/css/ace-rtl.min.css" />
		<link rel="stylesheet" href="${jpath}/static/assets/css/ace-skins.min.css" />

	
		<script src="${jpath}/static/assets/js/ace-extra.min.js"></script>
		<script src="${jpath}/js/system_plugins.js"></script>

	</head>
  
  <body>
			<div class="table-responsive">
				<table id="sample-table-1" class="table table-striped table-bordered table-hover">
					<thead>
						<tr>
							<th class="center">
								<label>
									<input type="checkbox" id="boxId" onclick="selectAll();" class="ace" />
									<span class="lbl"></span>
								</label>
							</th>
							<th>编号</th>
							<th>行业名称</th>
							<th>行业状态</th>
							<th>上级行业</th>
							<th>操作</th>
						</tr>
					</thead>

					<tbody>
						
						
					</tbody>
				</table>
				
			</div><!-- /.table-responsive -->
			
			<!-- 
			<div class="modal-footer no-margin-top" style="display:none" id="fy">
				<ul class="pagination pull-right no-margin">
					
				</ul>
			</div> -->
			<div class="clearfix form-actions">
				<div class="col-md-offset-3 col-md-9">
					<button class="btn btn-app btn-primary btn-sm" id="add" type="button">
						<i class="icon-edit bigger-230"></i>
						添加行业
					</button>
	
					<button class="btn btn-app btn-danger btn-sm" id="delAll" type="button">
						<i class="icon-trash bigger-200"></i>
						批量删除
					</button>
				</div>
			</div>
		<script type="text/javascript">
			function editThis(id){
				location.href="${jpath}/updateyhhy?id="+id;
				$.post("${jpath}/yonghuhangye/manager/uptadeyhhy",{id:id},function(data){
					var json = $.parseJSON(data);
					alert(json.resMsg);
					if(json.res==1){
						location.href="${jpath}/tables";
					}
				});
			}
			function delThis(id){
				if(confirm("确认删除")){
					$.post("${jpath}/yonghuhangye/manager/delyhhy",{id:id},function(data){
						var json = $.parseJSON(data);
						alert(json.resMsg);
						if(json.res==1){
							location.href="${jpath}/tables";
						}
					});
				}
			}
			function selectAll(){
				var box1=document.getElementById("boxId");
	            //checked判断是否选中
	            if(box1.checked==true)
	            {
			        // 获取要操作的复选框
		            var box1=document.getElementsByName("box");
		            //checked判断是否选中
		            for(var x=0;x<box1.length;x++)
		            {
		                var value1=box1[x];
		                value1.checked=true;
		            }
	            }else{
	                 // 获取要操作的复选框
		            var box2 = document.getElementsByName("box");
		             //checked判断是否选中
		           	for (var x = 0; x < box2.length; x++) {
		               var value1=box2[x];
		               value1.checked=false;
		            }
			    }
			}
			$(function(){
				//loadTbl(1,4);
				var colM=[{
						name:'id',
						cl:function(index,val){
							return '<label><input type="checkbox" name="box" id="box1" value="'+val.id+'" class="ace" /><span class="lbl"></span></label>';
						}
					},
					{
						name:'id'
					},
					{
						name:'hymc'
					},
					{
						name:'hyzt'
					},
					{
						name:'sjhy'
					},
					{
						name:'id',
						cl:function(index,val){
							var data="<div class='btn-group'>";
							data+="<button class='btn btn-xs btn-info' onclick='editThis(\""+val.id+"\")'><i class='icon-edit bigger-120'></i></button>";
							data+="<button class='btn btn-xs btn-danger' onclick='delThis(\""+val.id+"\")'><i class='icon-trash bigger-120'></i></button>";
							data+="</div>";
							return data;
						}
					}];
				var params = {pageNum:1,pageSize:4};
				$("#sample-table-1").loadTbl(colM,params,"${jpath}/yonghuhangye/manager/findByPage",true);
				$("#add").click(function(){
					location.href="${jpath}/addyhhy";
				});
				$("#delAll").click(function(){
				if(confirm("确认删除")){
					var cks = "";
					var c = $("tbody input:checked");
					for(var i =0;i< c.length;i++){
						var d =	c[i].value;
						cks+=d+",";
					}
					$.post("${jpath}/yonghuhangye/manager/delAllyhhy",{cks:cks},function(data){
						var json = $.parseJSON(data);
						alert(json.resMsg);
						if(json.res==1){
							location.href="${jpath}/tables";
						}
					});
					}
				});
			});
		</script>
  </body>
</html>
